package cn.kgc.mes.productrecpt.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.kgc.mes.common.annotation.Log;
import cn.kgc.mes.common.core.controller.BaseController;
import cn.kgc.mes.common.core.domain.AjaxResult;
import cn.kgc.mes.common.enums.BusinessType;
import cn.kgc.mes.productrecpt.domain.ProductRecpt;
import cn.kgc.mes.productrecpt.service.IProductRecptService;
import cn.kgc.mes.common.utils.poi.ExcelUtil;
import cn.kgc.mes.common.core.page.TableDataInfo;

/**
 * 产品入库录Controller
 * 
 * @author ruoyi
 * @date 2025-09-19
 */
@RestController
@RequestMapping("/productrecpt/productrecpt")
public class ProductRecptController extends BaseController
{
    @Autowired
    private IProductRecptService productRecptService;

    /**
     * 查询产品入库录列表
     */
//    @PreAuthorize("@ss.hasPermi('productrecpt:productrecpt:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProductRecpt productRecpt)
    {
        startPage();
        List<ProductRecpt> list = productRecptService.selectProductRecptList(productRecpt);
        return getDataTable(list);
    }

    /**
     * 导出产品入库录列表
     */
//    @PreAuthorize("@ss.hasPermi('productrecpt:productrecpt:export')")
    @Log(title = "产品入库录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProductRecpt productRecpt)
    {
        List<ProductRecpt> list = productRecptService.selectProductRecptList(productRecpt);
        ExcelUtil<ProductRecpt> util = new ExcelUtil<ProductRecpt>(ProductRecpt.class);
        util.exportExcel(response, list, "产品入库录数据");
    }

    /**
     * 获取产品入库录详细信息
     */
//    @PreAuthorize("@ss.hasPermi('productrecpt:productrecpt:query')")
    @GetMapping(value = "/{recptId}")
    public AjaxResult getInfo(@PathVariable("recptId") Long recptId)
    {
        return success(productRecptService.selectProductRecptByRecptId(recptId));
    }

    /**
     * 新增产品入库录
     */
//    @PreAuthorize("@ss.hasPermi('productrecpt:productrecpt:add')")
    @Log(title = "产品入库录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProductRecpt productRecpt)
    {
        return toAjax(productRecptService.insertProductRecpt(productRecpt));
    }

    /**
     * 修改产品入库录
     */
//    @PreAuthorize("@ss.hasPermi('productrecpt:productrecpt:edit')")
    @Log(title = "产品入库录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProductRecpt productRecpt)
    {
        return toAjax(productRecptService.updateProductRecpt(productRecpt));
    }

    /**
     * 删除产品入库录
     */
//    @PreAuthorize("@ss.hasPermi('productrecpt:productrecpt:remove')")
    @Log(title = "产品入库录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recptIds}")
    public AjaxResult remove(@PathVariable Long[] recptIds)
    {
        return toAjax(productRecptService.deleteProductRecptByRecptIds(recptIds));
    }
}
